package com.cobra.mall.util;

import cn.hutool.core.util.RandomUtil;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.io.IOException;

public class MallUtil {

    private static ObjectMapper mapper = new ObjectMapper();

    public static int getRandom(int start,int end){
      return   RandomUtil.randomInt(start,end);
    }

    public static <T> T fromJson2Obj(String json,Class<T> clazz) throws IOException {
        return mapper.readValue(json,clazz);
    }

    public static String fromObj2Json(Object obj) throws JsonProcessingException {
        return  mapper.writeValueAsString(obj);
    }

}
